package com.kazimsoylu.utils;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class BeanFactory 
{
	private static BeanFactory instance = null;
	
	private ApplicationContext applicationContext;
	
	private BeanFactory()
	{
		applicationContext = new ClassPathXmlApplicationContext( "classpath:appcontext/beans.xml" );
	}
	
	public synchronized static BeanFactory getInstance()
	{
		if( instance == null )
			instance = new BeanFactory();
		return instance;
	}
	
	public <T> T getBean( String beanId, Class<T> clazz )
	{
		return  (T) applicationContext.getBean( beanId );
		
	}
}
